﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CCF20Model.ConfigurationFile
{
    public class ZICMonitorLog : IConfiguration
    {
        
        private IConfiguration _previousConfig;
        private string strResult = string.Empty;

        public ZICMonitorLog(IConfiguration previousConfig)
        {
            _previousConfig = previousConfig;
        }

        public string VerifyResult()
        {
            WiseLinkConfiguration myConfig = ConfiguraitonHelper.MyConfiguration;

            string zicmonitorLogConnection = ConfiguraitonHelper.GetConfigValueFromAppConfig(AppConfigFileName.ZICMonitor, AppConfigFileNodeName.CCF20Log).ToLower();

            if (!zicmonitorLogConnection.Equals(string.Format("{0}\\ccf20.log", myConfig.logdir), StringComparison.OrdinalIgnoreCase))
            {
                ConfiguraitonHelper.SetConfigValueToAppConfig(AppConfigFileName.ZICMonitor, AppConfigFileNodeName.CCF20Log, string.Format("{0}\\ccf20.log", myConfig.logdir));
                strResult = "ZICMonitor AppConfig File CCF20Log Dir has different value than the configur.xml";
            }

            zicmonitorLogConnection = ConfiguraitonHelper.GetConfigValueFromAppConfig(AppConfigFileName.ZICMonitor, AppConfigFileNodeName.ZICDebug).ToLower();

            if (!zicmonitorLogConnection.Equals(string.Format("{0}\\zicdebug.log", myConfig.logdir), StringComparison.OrdinalIgnoreCase))
            {
                ConfiguraitonHelper.SetConfigValueToAppConfig(AppConfigFileName.ZICMonitor, AppConfigFileNodeName.ZICDebug, string.Format("{0}\\zicdebug.log", myConfig.logdir));
                strResult = string.Concat(strResult,"ZICMonitor AppConfig File ZICDebug Dir has different value than the configur.xml");
            }

            zicmonitorLogConnection = ConfiguraitonHelper.GetConfigValueFromAppConfig(AppConfigFileName.ZICMonitor, AppConfigFileNodeName.ZICMonitor).ToLower();

            if (!zicmonitorLogConnection.Equals(string.Format("{0}\\zicmonitor.log", myConfig.logdir), StringComparison.OrdinalIgnoreCase))
            {
                ConfiguraitonHelper.SetConfigValueToAppConfig(AppConfigFileName.ZICMonitor, AppConfigFileNodeName.ZICMonitor, string.Format("{0}\\zicmonitor.log", myConfig.logdir));
                strResult = string.Concat(strResult, "ZICMonitor AppConfig File ZICDebug Dir has different value than the configur.xml");
            }
            return string.Format("{0} \r\n{1}", _previousConfig.VerifyResult(), strResult);
        }

    }
}
